package com.zhouheng.module.login.database;

import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * 用户service
 *
 * @author 周恒
 * @date 20181003 10:37:59
 * @since v1.0
 */
@Service
public class UserService {

    public UserBean getUser(String username) {
        // 没有此用户直接返回null
        if (! DataSource.getData().containsKey(username)) {
            return null;
        }

        UserBean user = new UserBean();
        Map<String, String> detail = DataSource.getData().get(username);

        user.setUsername(username);
        user.setPassword(detail.get("password"));
        user.setRole(detail.get("role"));
        user.setPermission(detail.get("permission"));
        return user;
    }
}
